package com.ykq.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @program: 145ssm
 * @description:
 * @author: 闫克起2
 * @create: 2021-12-10 11:34
 **/
public class LoginInterceptor implements HandlerInterceptor {

    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Object user = request.getSession().getAttribute("user");
        if(user!=null){
             return true;
        }else{
            response.sendRedirect(request.getContextPath()+"/login.jsp");
            return false;
        }
    }
}
